<%--
  Created by IntelliJ IDEA.
  User: 33503
  Date: 2023/11/28
  Time: 20:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增教师</title>
    <!--引入jquery和bootstrap -->
    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <style>
        .teacher-box {
            background-color: white;
            color: black;
            margin-left: 230px;
            margin-top: 30px;
            border-radius: 10px
        }

        .in-teacher-box {
            background: rgba(255, 255, 255, 0.6);
            box-shadow: 4px 4px 4px 4px #337ab7;
            padding: 10px;
            margin: 20px;
            width: 50%;
            font-size: 20px;
            border-radius: 15px;
            background-color: #66afe9;
        }

        .in-teacher-box input {
            font-size: 20px;
        }

        td {
            border: 10px solid #66afe9;
            text-align: center;
            padding: 15px 0;
            /*background-color: #66afe9;*/
            height: 40px;
            font-size: 20px;
            color: black;
        }

        input::-webkit-input-placeholder {
            font-size: 15px;
        }
    </style>
</head>
<body>
<%--菜单栏--%>
<jsp:include page="management_menu.jsp"></jsp:include>
<div align="center" class="teacher-box">
    <div style="font-size: 30px">新增教师</div>
    <a href="${pageContext.request.contextPath }/teacherList" style="display: inline-block; background-color: #66afe9; font-size: 15px; float: left;color: black"><strong><</strong>返回上一级</a>
    <div align="center" class="in-teacher-box">
        <form action="${pageContext.request.contextPath }/addTeacher" method="post" id="addTForm">
            <table  style="font-size: large">
                <tr>
                    <td style="color: red; font-size: 20px" colspan="2">${wrongAddTMsg}</td>
                </tr>
                <tr><td>工&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</td><td><input type="text" name="t_id" id="t_id" placeholder="请输入教师工号"  onkeyup="value=value.replace(/[^\d]/g,'')" maxlength=9></td></tr>
                <tr><td>教师姓名：</td><td><input type="text" name="t_name" id="t_name" placeholder="请输入教师姓名"></td></tr>
                <tr><td>联系方式：</td><td><input type="text" name="t_phone" id="t_phone" placeholder="请输入联系方式"  onkeyup="value=value.replace(/[^\d]/g,'')"
                                                 maxlength=11></td></tr>
                <tr><td>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</td><td><input type="text" name="t_pwd" id="t_pwd" placeholder="请输入密码"></td></tr>
            </table>
            <br>
            <input type="button" value="确认" style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; border-radius: 5px; font-size: large; color: white; margin-right: 30px;" onclick="addt()"/>
            <input type="reset" value="重置" style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; border-radius: 5px; font-size: large; color: white;  margin-left: 50px;"/>
        </form>
    </div>
</div>
<script>
    function myTrim(x) {
        return x.replace(/^\s+|\s+$/gm, '');
    }
    function addt() {
        //提交form表单前判断
        var t_id = myTrim($("#t_id").val());//消除空格
        var t_name = myTrim($("#t_name").val());
        var t_phone = myTrim($("#t_phone").val());//消除空格
        var t_pwd = myTrim($("#t_pwd").val());
        if (t_id === "" || t_id == null) {
            alert("账号不能为空");
            return;
        } else if (t_name === "" || t_name == null) {
            alert("教师姓名不可为空");
            return;
        } else if (t_phone === "" || t_phone == null) {
            alert("联系方式不可为空");
            return;
        } else if (t_pwd === "" || t_pwd == null) {
            alert("密码不可为空");
            return;
        } else {
            //试题类型为单选题或多选题时，CD选项不可为空
            $("#addTForm").submit();
            alert("核验中***跳转成功即成功添加教师！")
            return false;
        }
    }
</script>
</body>
</html>
